use std::path::{Path, PathBuf};
use log::{warn};

fn list_directory_children<P: AsRef<Path>>(path: P) -> Vec<PathBuf> {
		let mut children = Vec::new();

		let entries = match path.as_ref().read_dir() {
			Ok(entries) => entries,
			Err(err) => {
				warn!("Unable to read directory '{}'.  The following error was received: {}", path.as_ref().display(), err);
				return Vec::new();
			}
		};

		for entry in entries {
			let entry = match entry {
				Ok(x) => x,
				Err(err) => {
					warn!("Unable to read contents of directory '{}'.  The following error was received: {}", path.as_ref().display(), err);
					return Vec::new();
				}
			};
            // entry is file or dir
			children.push(entry.path());
		}

		children
}
	
fn main() {
    let a=list_directory_children(PathBuf::from("/etc"));
    println!("result: {:?}", a);
}
